Allow interdomain channels to bind DOMID_SELF to DOMID_SELF.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 18 Oct 2005 10:04:48 +0000 (11:04 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 18 Oct 2005 10:04:48 +0000 (11:04 +0100)
Signed-off-by: Steve King <steven.r.king@intel.com>
xen/common/event_channel.c
xen/include/public/event_channel.h

index 8dd52eb49f7de43c316cb6e55dab9356a8e21865..f0feb65fd8c6ea3c6c44f9d8645d13b206ddef04 100644 (file)
@@ -89,7 +89,8 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
     chn = evtchn_from_port(d, port);
 
     chn->state = ECS_UNBOUND;
-    chn->u.unbound.remote_domid = alloc->remote_dom;
+    if ( (chn->u.unbound.remote_domid = alloc->remote_dom) == DOMID_SELF )
+        chn->u.unbound.remote_domid = current->domain->domain_id;
 
     alloc->port = port;
 
@@ -107,9 +108,13 @@ static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
     struct evtchn *lchn, *rchn;
     struct domain *ld = current->domain, *rd;
     int            lport, rport = bind->remote_port;
+    domid_t        rdom = bind->remote_dom;
     long           rc = 0;
 
-    if ( (rd = find_domain_by_id(bind->remote_dom)) == NULL )
+    if ( rdom == DOMID_SELF )
+        rdom = current->domain->domain_id;
+
+    if ( (rd = find_domain_by_id(rdom)) == NULL )
         return -ESRCH;
 
     /* Avoid deadlock by first acquiring lock of domain with smaller id. */
index 18bbd97c8677515292e6c7ddcefa2c0f30599a5e..1de10575120d6ca6069693bfce6423e71dfa72c7 100644 (file)
@@ -15,6 +15,7 @@
  * is allocated in <dom> and returned as <port>.
  * NOTES:
  *  1. If the caller is unprivileged then <dom> must be DOMID_SELF.
+ *  2. <rdom> may be DOMID_SELF, allowing loopback connections.
  */
 #define EVTCHNOP_alloc_unbound    6
 typedef struct evtchn_alloc_unbound {
@@ -30,6 +31,8 @@ typedef struct evtchn_alloc_unbound {
  * a port that is unbound and marked as accepting bindings from the calling
  * domain. A fresh port is allocated in the calling domain and returned as
  * <local_port>.
+ * NOTES:
+ *  2. <remote_dom> may be DOMID_SELF, allowing loopback connections.
  */
 #define EVTCHNOP_bind_interdomain 0
 typedef struct evtchn_bind_interdomain {